package com.crdeng.business.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

@Data
public class ProductCategoryVO  implements Serializable {

    @ApiModelProperty(value = "类别id")
    private Long id;

    @ApiModelProperty(value = "类别名称")
    private String name;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    private Date createTime;

    private Date modifiedTime;

    @ApiModelProperty(value = "父级分类id")
    private Long pid;

    @ApiModelProperty(value = "层级")
    private int lev;

    @ApiModelProperty(value = "子菜单")
    private List<ProductCategoryVO> children;

    /*
     * 排序,根据order排序
     */
    public static Comparator<ProductCategoryVO> order(){
        Comparator<ProductCategoryVO> comparator = (o1, o2) -> {
            if(o1.getSort() != o2.getSort()){
                return  (int) (o1.getSort() - o2.getSort());
            }
            return 0;
        };
        return comparator;
    }
}
